package server.net;

import java.io.Serializable;
import org.w3c.dom.Document;
import server.data.Customer;
import server.data.Router;

/**
 *
 * @author Danon
 */
public class OrderRequest extends Request implements Serializable  {

    public OrderRequest(Customer c, Router a, Router b) {
        super(c);
        src = a;
        dst = b;
    }
    
    public final Router getSource() {
        return src;
    }
    
    public final Router getDestination() {
        return dst;
    }
    
    @Override
    public String toString() {
        return "OrderRequest{customer:" + getCustomer() + "; id:"+getId()+
                "; src:" + getSource()+"; dst:"+getDestination()+"}";
    
    }
    
    public static OrderRequest createFromDOM(Document doc) {
        return new OrderRequest(Customer.createFromDOM(doc.getElementsByTagName("customer").item(0)),
                         Router.createFromDOM(doc.getElementsByTagName("src").item(0)),
                         Router.createFromDOM(doc.getElementsByTagName("dst").item(0)));
    }
    
    private Router src, dst;
}
